<?php

/**
 * Transaction form base class.
 *
 * @package    form
 * @subpackage transaction
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 8508 2008-04-17 17:39:15Z fabien $
 */
class BaseTransactionForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'                => new sfWidgetFormInputHidden(),
      'date'              => new sfWidgetFormDate(),
      'description'       => new sfWidgetFormTextarea(),
      'account_id'        => new sfWidgetFormDoctrineSelect(array('model' => 'Account', 'add_empty' => true)),
      'income_account_id' => new sfWidgetFormDoctrineSelect(array('model' => 'IncomeAccount', 'add_empty' => true)),
      'income'            => new sfWidgetFormInput(),
      'expense'           => new sfWidgetFormInput(),
    ));

    $this->setValidators(array(
      'id'                => new sfValidatorDoctrineChoice(array('model' => 'Transaction', 'column' => 'id', 'required' => false)),
      'date'              => new sfValidatorDate(),
      'description'       => new sfValidatorString(array('required' => false)),
      'account_id'        => new sfValidatorDoctrineChoice(array('model' => 'Account', 'required' => false)),
      'income_account_id' => new sfValidatorDoctrineChoice(array('model' => 'IncomeAccount', 'required' => false)),
      'income'            => new sfValidatorNumber(array('required' => false)),
      'expense'           => new sfValidatorNumber(array('required' => false)),
    ));

    $this->widgetSchema->setNameFormat('transaction[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Transaction';
  }

}